﻿using PizzaService.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PizzaService.View
{
    /// <summary>
    /// Interaction logic for EditFoodWindow.xaml
    /// </summary>
    public partial class EditFoodWindow : Window
    {
        public EditFoodWindow()
        {
            InitializeComponent();
            this.Loaded += EditFoodWindow_Loaded;
        }

        void EditFoodWindow_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = App.Controller.EditFViewModel;
        }
        /// <summary>
        /// ExtraZutat Fenster öffnet sich
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AllExtraZutaten_Click(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is Button)
            {
            var item = (e.OriginalSource as Button).DataContext;

            App.Controller.AddExtraZutat(item);
            }
        }
        /// <summary>
        /// ExtraZutat hinzufügen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddedExtraZutaten_Click(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is Button)
            {
            var item = (e.OriginalSource as Button).DataContext;

            App.Controller.RemoveExtraZutat(item);
            }
        }
        /// <summary>
        /// OK Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            App.Controller.AddFood();

            this.Close();
        }
        /// <summary>
        /// Cancel Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnCancel_CLick(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

    }
}
